package com.pucong.gitee.database.backup.business.database.util;

import com.pucong.gitee.database.backup.common.entity.database.BackupDatabase;
import com.pucong.gitee.database.backup.common.selfenum.DatabaseTypeEnum;
import com.pucong.gitee.database.backup.business.database.mapper.BackupExeSqlLogMapper;

public class BackupServiceFactory {

    /**
     * 工厂生产sql执行器
     * @param backupDatabase
     * @param backupExeSqlLogMapper
     * @return
     */
    public OperationService getBackupService(BackupDatabase backupDatabase, BackupExeSqlLogMapper backupExeSqlLogMapper) {
        DatabaseTypeEnum databaseType = backupDatabase.getDatabaseType();
        OperationService operationService = null;
        switch (databaseType){
            case oracle:
                operationService = new OperationServiceOracleImpl(backupDatabase,backupExeSqlLogMapper);
                break;
            case mysql:
                operationService = new OperationServiceMysqlImpl(backupDatabase,backupExeSqlLogMapper);
                break;
            case postgresql:
                operationService = new OperationServicePgsqlImpl(backupDatabase,backupExeSqlLogMapper);
                break;
            case sqlserver:
                operationService = new OperationServiceMssqlImpl(backupDatabase,backupExeSqlLogMapper);
                break;
            case hive:
                operationService = new OperationServiceHivelImpl(backupDatabase,backupExeSqlLogMapper);
                break;
        }
        return operationService;
    }

}